package com.nervenets.web.controller.handler.user.news;

import com.nervenets.web.controller.handler.Handler;
import com.nervenets.web.controller.handler.common.IdParams;
import com.nervenets.web.entity.MessageCode;
import com.nervenets.web.hibernate.domain.news.News;

import javax.servlet.http.HttpServletRequest;

public class NewsDetailHandler extends Handler<IdParams> {
    @Override
    public String handle(IdParams params, HttpServletRequest request) throws Exception {
        final News news = userDao.findById(params.getTargetId(), News.class);
        if (null == news) return errorMessage(MessageCode.code_404, "资讯不存在");
        return successMessage(news);
    }

    @Override
    public String result() throws Exception {
        return successMessage(new News());
    }
}
